using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TheNorthStar.Api.Results;
using TheNorthStar.Api.Requests;
using NorthStar.Driver.Application;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace NorthStar.Driver
{
    [Activity(Label = "Picked Up")]
    public class SendingActivity : Activity
    {
        string m_bookingId;
        string m_driverId;
        private string GetBookingID()
        {
            return Intent.GetStringExtra( "bookingID" );
        }
        private string GetDriverID()
        {
            return Intent.GetStringExtra("driverID");
        }
        private void CompleteJob()
        {
            m_bookingId = GetBookingID();
            m_driverId = GetDriverID();
            DriverLogon driver = new DriverLogon();
            Booking booking = new Booking();
            driver.driverID = Int32.Parse( m_driverId );
            booking.BookingId = Int32.Parse( m_bookingId );
            var api = new ConnectToSever(Helper.GetServer(ApplicationContext));
            api.CompleteJob( driver,booking );
            /*var rate = new Intent(this, typeof(RateActivity));
            rate.PutExtra( "driverId", m_driverId );
            rate.PutExtra("bookingId", m_bookingId);
            StartActivity(rate);*/

            Intent a = new Intent(this, typeof(MainActivity));
            a.AddFlags(ActivityFlags.ClearTop);
            a.PutExtra("driverID", m_driverId);
            StartActivity(a);

        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SendingLayout);
            Button button = FindViewById<Button>(Resource.Id.DoneButton);
            button.Click += delegate
            {
                CompleteJob();
            };
            // Create your application here
        }
    }
}